Quicksort with median of medians is considered practical
نویسنده
چکیده
Quicksort[2, 1, 3] is one of the most efficient and widely used sorting algorithms. The major drawback of quicksort is that worst case time complexity of naive implementations of quicksort is O(n2) with input size n. In order to avoid this worst case behavior, a variant of quicksort, so-called introsort[4] 1 , is often used. There exists another solution to keep the worst case complexity of quicksort O(n ln n). This is the use of median-of-medians or Blum-Floyd-Pratt-Rivest-Tarjan (BFPRT) algorithm — the pivot selection algorithm in the linear median finding algorithm[6]. Despite the theoretical importance of this scheme, because of its somewhat large constant factor, this method have been considered impractical to use as a pivot selection algorithm in quicksort. In this article, contrary to the above widespread view, we show that using BFPRT in quicksort is not inefficient, and moreover, considered practical. Indeed, we find that quicksort with median-of-medians shows comparable performance to the well-known optimized quicksort implementations[7, 8] for random sequence. We also show that the technique for improving performance is not only for the BFPRT but also available for other pivoting methods.
منابع مشابه
A numerical analysis of Quicksort: How many cases are bad cases?
We present numerical results for the probability of bad cases for Quicksort, i. e. cases of input data for which the sorting cost considerably exceeds that of the average. Dynamic programming was used to compute solutions of the recurrence for the frequency distributions of comparisons. From these solutions, probabilities of numbers of comparisons above certain thresholds relative to the averag...
متن کاملOptimal Sampling Strategies in Quicksort and Quickselect
It is well known that the performance of quicksort can be improved by selecting the median of a sample of elements as the pivot of each partitioning stage. For large samples the partitions are better, but the amount of additional comparisons and exchanges to find the median of the sample also increases. We show in this paper that the optimal sample size to minimize the average total cost of qui...
متن کاملAn Algorithm For Fast Median Search
Searching for a median of a set of patterns is a well-known technique to model the set or to aid searching for more accurate models such as a generalized median or a k-median. While medians and generalized medians are (relatively) easy to compute in the case of Euclidean representation spaces, this is unfortunately no longer true when more complex distance measures are to be used, which often h...
متن کاملMedians and means in Riemannian geometry: existence, uniqueness and computation
This paper is a short summary of our recent work on the medians and means of probability measures in Riemannian manifolds. Firstly, the existence and uniqueness results of local medians are given. In order to compute medians in practical cases, we propose a subgradient algorithm and prove its convergence. After that, Fréchet medians are considered. We prove their statistical consistency and giv...
متن کاملA Practical Quicksort Algorithm for Graphics Processors
In this paper we present GPU-Quicksort, an efficient Quicksort algorithm suitable for highly parallel multi-core graphics processors. Quicksort has previously been considered as an inefficient sorting solution for graphics processors, but we show that GPU-Quicksort often performs better than the fastest known sorting implementations for graphics processors, such as radix and bitonic sort. Quick...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید
ثبت ناماگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید
ورودعنوان ژورنال:
- CoRR
دوره abs/1608.04852 شماره
صفحات -
تاریخ انتشار 2016